﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

using Checkers.Sever.DBModule.databaseProxy;

namespace Checkers.Service.WCFService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "LoginService" in code, svc and config file together.
    public class LoginService : ILoginService
    {

        public IDatabaseUtility IDBUtil;

        public LoginService() 
        {
            IDBUtil = clsDatabaseUtility.getInstance();
        }

        public databaseProxyDataContract.clsPlayer Singup(databaseProxyDataContract.clsPlayer objClsPlayer)
        {
            var objPlayer = IDBUtil.AddPlayerProfile(objClsPlayer.PlayerName, objClsPlayer.PlayerUserName, objClsPlayer.PlayerPassword);
            objClsPlayer.PlayerId = objPlayer.playerId;

            return objClsPlayer;   
        }

        public databaseProxyDataContract.clsPlayer LoginAuthentication(databaseProxyDataContract.clsPlayer objClsPlayer)
        {
            var objPlayer = IDBUtil.AuthenticatePlayer(objClsPlayer.PlayerUserName, objClsPlayer.PlayerPassword);

            objClsPlayer.PlayerName = objPlayer.playerName;
            objClsPlayer.PlayerId = objPlayer.playerId;

            return objClsPlayer;

        }
    }

    
}
